package lgs.hm.config;

import java.util.Map;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice  //只能注入Model，Map注入不进来
public class ErrorHandler {
	
	@ExceptionHandler(Exception.class)//声明一个异常就能拦截
	@ResponseBody
	public Object handerAll(Exception e) {
		return "赶紧给项目经理打电话，再睡就天亮了"+e.getMessage();
	}
	
	@ExceptionHandler(NullPointerException.class)
//	@ResponseBody
	public String handerNullPoint(Exception e,Model model) {
//		map.put("e", e);
		model.addAttribute("e",e);
		return "error/null"; //null.jsp
		
	}

}
